package com.situ.springmvc.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class MyInterceptor1 implements HandlerInterceptor{
	public MyInterceptor1() {
		System.out.println("MyInterceptor1.MyInterceptor1()");
	}

	/**
	 * 执行Controller里面方法之前会先执行这个方法
	 * pre:previous
	 * 返回true代表继续执行，返回false代表终止执行。
	 * 用户权限的验证、是否登录的验证都可以写到这里
	 */
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
		System.out.println("MyInterceptor1.preHandle()");
		
		return true;
	}
	
	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		System.out.println("MyInterceptor1.postHandle()");
	}
	
	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		System.out.println("MyInterceptor1.afterCompletion()");
	}

	

	

}
